<?php

namespace App\Http\Search\Rbac;

use App\Http\Model\ConstCode;
use App\Http\Model\Rbac\NodeModel;
use App\Http\Search\BaseSearch;

class NodeSearch extends BaseSearch
{

    public function index()
    {
        $where = [
            'NodeStatus' => ConstCode::BASIC_STATUS_NORMAL,
        ];
        $select = [
            'NodeID', 'ControllerName', 'ActionName', 'NodeName', 'NodeOrder', 'NodeShowType',
            'NodeStatus', 'NodeType', 'ParentID', 'NodeIcon'
        ];
        $list   = NodeModel::query()->where($where)
            ->select($select)
            ->orderBy('ParentID')
            ->orderBy('NodeOrder')
            ->get()->toArray();
        return [
            'list'  => $list,
            'count' => count($list)
        ];
    }

}
